home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Utilities / vim-5.1 / doc / term.txt < prev    next >
Encoding:
Text File  |  1998-04-05  |  27.5 KB  |  628 lines

  1. *term.txt*      For Vim version 5.1.  Last modification: 1998 Mar 29
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Terminal information                    *terminal-info*
  8.  
  9. Vim uses information about the terminal you are using to fill the screen and
  10. recognize what keys you hit.  If this information is not correct the screen
  11. may be messed up or keys may not be recognized.  The actions which have to be
  12. performed on the screen are accomplished by outputting a string of
  13. characters.  Special keys produce a string of characters.  These strings are
  14. stored in the terminal options, see |terminal-options|.
  15.  
  16. 1. Startup            |startup-terminal|
  17. 2. Terminal options        |terminal-options|
  18. 3. Window size            |window-size|
  19. 4. Slow and fast terminals    |slow-fast-terminal|
  20. 5. Using the mouse        |mouse-using|
  21.  
  22. ==============================================================================
  23. 1. Startup                        *startup-terminal*
  24.  
  25. When Vim is started a default terminal type is assumed.  For the Amiga this is
  26. a standard CLI window, for MS-DOS the pc terminal, for Unix an ansi terminal.
  27. A few other terminal types are always available, see below |builtin-terms|.
  28.  
  29. You can give the terminal name with the '-T' Vim argument.  If it is not given
  30. Vim will try to get the name from the TERM environment variable.
  31.  
  32.                             *termcap* *terminfo*
  33. On Unix the terminfo database or termcap file is used.  This is referred to as
  34. "termcap" in all the documentation.  At compile time, when running configure,
  35. the choice whether to use terminfo or termcap is done automatically.  When
  36. running Vim the output of ":version" will show |+terminfo| if terminfo is
  37. used.  Also see |xterm-screens|.
  38.  
  39. On non-Unix systems a termcap is only available if Vim was compiled with
  40. TERMCAP defined.
  41.  
  42.                     *builtin-terms* *builtin_terms*
  43. Which builtin terminals are available depends on a few defines in feature.h,
  44. which needs to be set at compile time:
  45.     define        output of ":version"    terminals builtin    ~
  46. NO_BUILTIN_TCAPS    -builtin_terms        none
  47. SOME_BUILTIN_TCAPS    +builtin_terms        most common ones (default)
  48. ALL_BUILTIN_TCAPS    ++builtin_terms        all available
  49.  
  50. You can see a list of available builtin terminals with ":set term=xxx" (when
  51. not running the GUI).  Also see |+builtin_terms|.
  52.  
  53. If the termcap code is included Vim will try to get the strings for the
  54. terminal you are using from the termcap file and the builtin termcaps.  Both
  55. are always used, if an entry for the terminal you are using is present.  Which
  56. one is used first depends on the 'ttybuiltin' option:
  57.  
  58. 'ttybuiltin' on        1: builtin termcap    2: external termcap
  59. 'ttybuiltin' off    1: external termcap    2: builtin termcap
  60.  
  61. If an option is missing in one of them, it will be obtained from the other
  62. one.  If an option is present in both, the one first encountered is used.
  63.  
  64. Which external termcap file is used varies from system to system and may
  65. depend on the environment variables "TERMCAP" and "TERMPATH".  See "man
  66. tgetent".
  67.  
  68. Settings depending on terminal            *term-dependent-settings*
  69.  
  70. If you want to set options or mappings, depending on the terminal name, you
  71. can do this best in your .vimrc.  Example:
  72.  
  73. >   if &term == "xterm"
  74. >     ... xterm maps and settings ...
  75. >   else if &term =~ "vt10."
  76. >     ... vt100, vt102 maps and settings ...
  77. >   endif
  78.  
  79.                         *raw-terminal-mode*
  80. For normal editing the terminal will be put into "raw" mode.  The strings
  81. defined with 't_ti' and 't_ks' will be sent to the terminal.  Normally this
  82. puts the terminal in a state where the termcap codes are valid and activates
  83. the cursor and function keys.  When Vim exits the terminal will be put back
  84. into the mode it was before Vim started.  The strings defined with 't_te' and
  85. 't_ke' will be sent to the terminal.  On the Amiga with commands that execute
  86. an external command (e.g., "!!") the terminal will be put into Normal mode for
  87. a moment.  This means that you can stop the output to the screen by hitting a
  88. printing key.  Output resumes when you hit <BS>.
  89.  
  90.                             *cs7-problem*
  91. Note: If the terminal settings are changed after running Vim, you might have
  92. an illegal combination of settings.  This has been reported on Solaris 2.5
  93. with "stty cs8 parenb", which is restored as "stty cs7 parenb".  Use
  94. "stty cs8 -parenb -istrip" instead, this is restored correctly.
  95.  
  96. Some termcap entries are wrong in the sense that after sending 't_ks' the
  97. cursor keys send codes different from the codes defined in the termcap.  To
  98. avoid this you can set 't_ks' (and 't_ke') to empty strings.  This must be
  99. done during initialization (see |initialization|), otherwise its too late.
  100.  
  101. Some termcap entries assume that the highest bit is always reset.  For
  102. example: The cursor-up entry for the amiga could be ":ku=\EA:".  But the Amiga
  103. really sends "\233A".  This works fine if the highest bit is reset, e.g., when
  104. using an Amiga over a serial line.  If the cursor keys don't work, try the
  105. entry ":ku=\233A:".
  106.  
  107. Some termcap entries have the entry ":ku=\E[A:".  But the Amiga really sends
  108. "\233A".  On output "\E[" and "\233" are often equivalent, on input they
  109. aren't.  You will have to change the termcap entry, or change the key code with
  110. the :set command to fix this.
  111.  
  112. Many cursor key codes start with an <Esc>.  Vim must find out if this a single
  113. hit of the <Esc> key or the start of a cursor key sequence.  It waits for a
  114. next character to arrive.  If it does not arrive within one second a single
  115. <Esc> is assumed.  On very slow systems this may fail, causing cursor keys not
  116. to work sometimes.  If you discover this problem reset the 'timeout' option.
  117. Vim will wait for the next character to arrive after an <Esc>.  If you want to
  118. enter a single <Esc> you must type it twice.  Resetting the 'esckeys' option
  119. avoids this problems in Insert mode, but you lose the possibility to use
  120. cursor and function keys in Insert mode.
  121.  
  122. On the Amiga the recognition of window resizing is activated only when the
  123. terminal name is "amiga" or "builtin_amiga".
  124.  
  125. Some terminals have confusing codes for the cursor keys.  The televideo 925 is
  126. such a terminal.  It sends a CTRL-H for cursor-left.  This would make it
  127. impossible to distinguish a backspace and cursor-left.  To avoid this problem
  128. CTRL-H is never recognized as cursor-left.
  129.  
  130.                     *vt100-cursor-keys* *xterm-cursor-keys*
  131. Other terminals (e.g., vt100 and xterm) have cursor keys that send <Esc>OA,
  132. <Esc>OB, etc.  Unfortunately these are valid commands in insert mode: Stop
  133. insert, Open a new line above the new one, start inserting 'A', 'B', etc.
  134. Instead of performing these commands Vim will recognize this key sequence as a
  135. cursor key movement.  To avoid this you could use these settings:
  136.     :set notimeout        " don't timeout on mappings
  137.     :set ttimeout        " do timeout on terminal key codes
  138.     :set timeoutlen=100    " timemout in 100 msec
  139. This requires the keys to be hit withing 100msec.  When you type you normally
  140. are not that fast.  The cursor key codes arrive within 100 msec, so they are
  141. still recognized.
  142.  
  143.                 *vt100-function-keys* *xterm-function-keys*
  144. An xterm can send function keys F1 to F4 in two modes: vt100 compatible or
  145. not.  Because Vim cannot know what the xterm is sending, both types of keys
  146. are recognized:
  147.                     normal        vt100 ~
  148.     <F1>>    t_k1    <Esc>[11~    <Esc>OP
  149.     <F2>    t_k2    <Esc>[12~    <Esc>OQ
  150.     <F3>    t_k3    <Esc>[13~    <Esc>OR
  151.     <F4>    t_k4    <Esc>[14~    <Esc>OS
  152.  
  153.                             *xterm-scroll-region*
  154. The default termcap entry for xterm on sun and other platforms does not
  155. contain the entry for scroll regions.  Add ":cs=\E[%i%d;%dr:" to the xterm
  156. entry in /etc/termcap and everything should work.
  157.  
  158.                             *xterm-end-home-keys*
  159. On some systems (at least on FreeBSD with X386 3.1.2) the codes that the <End>
  160. and <Home> keys send contain a <Nul> character.  To make these keys send the
  161. proper key code, add these lines to your ~/.Xdefaults file:
  162.  
  163. *VT100.Translations:        #override \n\
  164.         <Key>Home: string("0x1b") string("[7~") \n\
  165.         <Key>End: string("0x1b") string("[8~")
  166.  
  167. ==============================================================================
  168. 2. Terminal options                    *terminal-options*
  169.  
  170. The terminal options can be set just like normal options.  But they are not
  171. shown with the ":set all" command.  Instead use ":set termcap".
  172.  
  173. It is always possible to change individual strings by setting the
  174. appropriate option.  For example:
  175. >    :set t_ce=^V^[[K    (CTRL-V, <Esc>, [, K)
  176.  
  177. {Vi: no terminal options.  You have to exit Vi, edit the termcap entry and
  178. try again}
  179.  
  180. The options are listed below.  The associated termcap code is always equal to
  181. the last two characters of the option name.  Two termcap codes are required:
  182. Cursor positioning and clear screen.
  183.  
  184. The options 't_da', 't_db', 't_ms', 't_xs' represent flags in the termcap.
  185. When the termcap flag is present, the option will be set to "y".  But any
  186. non-empty string means that the flag is set.  An empty string means that the
  187. flag is set.  't_CS' works like this too, but it isn't a termcap flag.
  188.  
  189. OUTPUT CODES
  190.     option    meaning    ~
  191.  
  192.     t_AB    set background color (ANSI)            *t_AB* *'t_AB'*
  193.     t_AF    set foreground color (ANSI)            *t_AF* *'t_AF'*
  194.     t_AL    add number of blank lines            *t_AL* *'t_AL'*
  195.     t_al    add new blank line                *t_al* *'t_al'*
  196.     t_bc    backspace character                *t_bc* *'t_bc'*
  197.     t_cd    clear to end of screen                *t_cd* *'t_cd'*
  198.     t_ce    clear to end of line                *t_ce* *'t_ce'*
  199.     t_cl    clear screen (required!)            *t_cl* *'t_cl'*
  200.     t_cm    cursor motion (required!)            *t_cm* *'t_cm'*
  201.     t_Co    number of colors                *t_Co* *'t_Co'*
  202.     t_CS    if non-empty, cursor relative to scroll region    *t_CS* *'t_CS'*
  203.     t_cs    define scrolling region                *t_cs* *'t_cs'*
  204.     t_da    if non-empty, lines from above scroll down    *t_da* *'t_da'*
  205.     t_db    if non-empty, lines from below scroll up    *t_db* *'t_db'*
  206.     t_DL    delete number of lines                *t_DL* *'t_DL'*
  207.     t_dl    delete line                    *t_dl* *'t_dl'*
  208.     t_ke    out of "keypad transmit" mode            *t_ke* *'t_ke'*
  209.     t_ks    put terminal in "keypad transmit" mode        *t_ks* *'t_ks'*
  210.     t_le    move cursor one char left            *t_le* *'t_le'*
  211.     t_mb    blinking mode                    *t_mb* *'t_mb'*
  212.     t_md    bold mode                    *t_md* *'t_md'*
  213.     t_me    Normal mode (undoes t_mr, t_mb and t_md)    *t_me* *'t_me'*
  214.     t_mr    reverse (invert) mode                *t_mr* *'t_mr'*
  215.                                 *t_ms* *'t_ms'*
  216.     t_ms    if non-empty, cursor can be moved in standout/inverse mode
  217.     t_nd    non destructive space character            *t_nd* *'t_nd'*
  218.     t_op    reset to original color pair            *t_op* *'t_op'*
  219.     t_RI    cursor number of chars right            *t_RI* *'t_RI'*
  220.     t_Sb    set background color                *t_Sb* *'t_Sb'*
  221.     t_Sf    set foreground color                *t_Sf* *'t_Sf'*
  222.     t_se    standout end                    *t_se* *'t_se'*
  223.     t_so    standout mode                    *t_so* *'t_so'*
  224.     t_sr    scroll reverse (backward)            *t_sr* *'t_sr'*
  225.     t_te    out of "termcap" mode                *t_te* *'t_te'*
  226.     t_ti    put terminal in "termcap" mode            *t_ti* *'t_ti'*
  227.     t_ue    underline end                    *t_ue* *'t_ue'*
  228.     t_us    underline mode                    *t_us* *'t_us'*
  229.     t_vb    visual bell                    *t_vb* *'t_vb'*
  230.     t_ve    cursor visible                    *t_ve* *'t_ve'*
  231.     t_vi    cursor invisible                *t_vi* *'t_vi'*
  232.     t_vs    cursor very visible                *t_vs* *'t_vs'*
  233.                                 *t_xs* *'t_xs'*
  234.     t_xs    if non-empty, standout not erased by overwriting (hpterm)
  235.     t_ZH    italics mode                    *t_ZH* *'t_ZH'*
  236.     t_ZR    italics end                    *t_ZR* *'t_ZR'*
  237.  
  238. KEY CODES
  239. Note: Use the <> form if possible
  240.  
  241.     option    name        meaning    ~
  242.  
  243.     t_ku    <Up>        arrow up            *t_ku* *'t_ku'*
  244.     t_kd    <Down>        arrow down            *t_kd* *'t_kd'*
  245.     t_kr    <Right>        arrow right            *t_kr* *'t_kr'*
  246.     t_kl    <Left>        arrow left            *t_kl* *'t_kl'*
  247.         <S-Up>        shift arrow up
  248.         <S-Down>    shift arrow down
  249.     t_%i    <S-Right>    shift arrow right        *t_%i* *'t_%i'*
  250.     t_#4    <S-Left>    shift arrow left        *t_#4* *'t_#4'*
  251.     t_k1    <F1>        function key 1            *t_k1* *'t_k1'*
  252.     t_k2    <F2>        function key 2             *t_k2* *'t_k2'*
  253.     t_k3    <F3>        function key 3             *t_k3* *'t_k3'*
  254.     t_k4    <F4>        function key 4             *t_k4* *'t_k4'*
  255.     t_k5    <F5>        function key 5             *t_k5* *'t_k5'*
  256.     t_k6    <F6>        function key 6             *t_k6* *'t_k6'*
  257.     t_k7    <F7>        function key 7             *t_k7* *'t_k7'*
  258.     t_k8    <F8>        function key 8             *t_k8* *'t_k8'*
  259.     t_k9    <F9>        function key 9             *t_k9* *'t_k9'*
  260.     t_k;    <F10>        function key 10         *t_k;* *'t_k;'*
  261.     t_F1    <F11>        function key 11         *t_F1* *'t_F1'*
  262.     t_F2    <F12>        function key 12         *t_F2* *'t_F2'*
  263.         <S-F1)        shifted function key 1
  264.         <S-F2>        shifted function key 2
  265.         <S-F3>        shifted function key 3
  266.         <S-F4>        shifted function key 4
  267.         <S-F5>        shifted function key 5
  268.         <S-F6>        shifted function key 6
  269.         <S-F7>        shifted function key 7
  270.         <S-F8>        shifted function key 8
  271.         <S-F9>        shifted function key 9
  272.         <S-F10>        shifted function key 10
  273.         <S-F11>        shifted function key 11
  274.         <S-F12>        shifted function key 12
  275.     t_%1    <Help>        help key            *t_%1* *'t_%1'*
  276.     t_&8    <Undo>        undo key            *t_&8* *'t_&8'*
  277.     t_kI    <Insert>    insert key            *t_kI* *'t_kI'*
  278.     t_kD    <Delete>    delete key            *t_kD* *'t_kD'*
  279.     t_kb    <BS>        backspace key            *t_kb* *'t_kb'*
  280.     t_kh    <Home>        home key            *t_kh* *'t_kh'*
  281.     t_@7    <End>        end key                *t_@7* *'t_@7'*
  282.     t_kP    <PageUp>    page-up key            *t_kP* *'t_kP'*
  283.     t_kN    <PageDown>    page-down key            *t_kN* *'t_kN'*
  284.     t_K1    <kHome>        keypad home key            *t_K1* *'t_K1'*
  285.     t_K4    <kEnd>        keypad end key            *t_K4* *'t_K4'*
  286.     t_K3    <kPageUp>    keypad page-up key        *t_K3* *'t_K3'*
  287.     t_K5    <kPageDown>    keypad page-down key        *t_K5* *'t_K5'*
  288.  
  289. Note about t_so and t_mr: When the termcap entry "so" is not present the
  290. entry for "mr" is used.  And vice versa.  The same is done for "se" and "me".
  291. If your terminal supports both inversion and standout mode, you can see two
  292. different modes.  If you terminal supports only one of the modes, both will
  293. look the same.
  294.  
  295.                             *termcap-colors*
  296. Note about colors: The 't_Co' option tells Vim the number of colors available.
  297. When it is non-zero, the 't_AB' and 't_AF' options are used to set the color.
  298. If one of these is not available, 't_Sb' and 't_Sf' are used.
  299.  
  300.                             *hpterm*
  301. If inversion or other highlighting does not work correctly, try setting the
  302. 't_xs' option to a non-empty string.  This makes the 't_ce' code be used to
  303. remove highlighting from a line.  This is required for "hpterm".  Setting the
  304. 'weirdinvert' option has the same effect as making 't_xs' non-empty, and vise
  305. versa.
  306.  
  307. Some termcaps do not include an entry for 'cs' (scroll region), although the
  308. terminal does support it.  For example: xterm on a sun.  You can use the
  309. builtin_xterm or define t_cs yourself.  For example:
  310. >    :set t_cs=^V^[[%i%d;%dr
  311.  
  312. Where ^V is CTRL-V and ^[ is <Esc>.
  313.  
  314. Unfortunately it is not possible to deduce from the termcap how cursor
  315. positioning should be done when using a scrolling region: Relative to the
  316. beginning of the screen or relative to the beginning of the scrolling region.
  317. Most terminals use the first method.  A known exception is the MS-DOS console
  318. (pcterm).  The 't_CS' option should be set to any string when cursor
  319. positioning is relative to the start of the scrolling region.  It should be
  320. set to an empty string otherwise.  It is default "yes" when 'term' is
  321. "pcterm".
  322.  
  323. Note for xterm users: The shifted cursor keys normally don't work.  You can
  324.     make them work with the xmodmap command and some mappings in Vim.
  325.  
  326.     Give these commands in the xterm:
  327.         xmodmap -e "keysym Up = Up F13"
  328.         xmodmap -e "keysym Down = Down F16"
  329.         xmodmap -e "keysym Left = Left F18"
  330.         xmodmap -e "keysym Right = Right F19"
  331.  
  332.     And use these mappings in Vim:
  333.         :map <t_F3> <S-Up>
  334.         :map! <t_F3> <S-Up>
  335.         :map <t_F6> <S-Down>
  336.         :map! <t_F6> <S-Down>
  337.         :map <t_F8> <S-Left>
  338.         :map! <t_F8> <S-Left>
  339.         :map <t_F9> <S-Right>
  340.         :map! <t_F9> <S-Right>
  341.  
  342. Instead of, say, <S-Up> you can use any other command that you want to use the
  343. shift-cursor-up key for.  (Note: To help people that have a Sun keyboard with
  344. left side keys F14 is not used because it is confused with the undo key; F15
  345. is not used, because it does a window-to-front; F17 is not used, because it
  346. closes the window.  On other systems you can probably use them)
  347.  
  348. ==============================================================================
  349. 3. Window size                        *window-size*
  350.  
  351. [This is about the size of the whole window Vim is using, not a window that is
  352. created with the :split command]
  353.  
  354. If you are running Vim on an Amiga and the terminal name is "amiga" or
  355. "builtin_amiga", the amiga-specific window resizing will be enabled.  On Unix
  356. systems three methods are tried to get the window size:
  357.  
  358. - an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
  359. - the environment variables "LINES" and "COLUMNS"
  360. - from the termcap entries "li" and "co"
  361.  
  362. If everything fails a default size of 24 lines and 80 columns is assumed.  If
  363. a window-resize signal is received the size will be set again.  If the window
  364. size is wrong you can use the 'lines' and 'columns' options to set the
  365. correct values.
  366.  
  367. One command can be used to set the screen size:
  368.  
  369.                             *:mod* *:mode*
  370. :mod[e] [mode]
  371.  
  372. Without argument this only detects the screen size.  With MS-DOS it is
  373. possible to switch screen mode.  [mode] can be one of these values:
  374.     "bw40"        40 columns black&white
  375.     "c40"        40 columns color
  376.     "bw80"        80 columns black&white
  377.     "c80"        80 columns color (most people use this)
  378.     "mono"        80 columns monochrome
  379.     "c4350"        43 or 50 lines EGA/VGA mode
  380.     number        mode number to use, depends on your video card
  381.  
  382. ==============================================================================
  383. 4. Slow and fast terminals            *slow-fast-terminal*
  384.                         *slow-terminal*
  385.  
  386. If you have a fast terminal you may like to set the 'ruler' option.  The
  387. cursor position is shown in the status line.  If you are using horizontal
  388. scrolling ('wrap' option off) consider setting 'sidescroll' to a small
  389. number.
  390.  
  391. If you have a slow terminal you may want to reset the 'showcmd' option.
  392. The command characters will not be shown in the status line.  If the terminal
  393. scrolls very slowly, set the 'scrolljump' to 5 or so.  If the cursor is moved
  394. off the screen (e.g., with "j") Vim will scroll 5 lines at a time.  Another
  395. possibility is to reduce the number of lines that Vim uses with the command
  396. "z<height><CR>".
  397.  
  398. If the characters from the terminal are arriving with more than 1 second
  399. between them you might want to set the 'timeout' and/or 'ttimeout' option.
  400. See the "Options" chapter |options|.
  401.  
  402. If your terminal does not support a scrolling region, but it does support
  403. insert/delete line commands, scrolling with multiple windows may make the
  404. lines jump up and down.  If you don't want this set the 'ttyfast' option.
  405. This will redraw the window instead of scroll it.
  406.  
  407. If your terminal scrolls very slowly, but redrawing is not slow, set the
  408. 'ttyscroll' option to a small number, e.g., 3.  This will make Vim redraw the
  409. screen instead of scrolling, when there are more than 3 lines to be scrolled.
  410.  
  411. If you are using Vim over a slow serial line, you might want to try running
  412. Vim inside the "screen" program.  Screen will optimize the terminal I/O quite
  413. a bit.
  414.  
  415. If you are testing termcap options, but you cannot see what is happening,
  416. you might want to set the 'writedelay' option.  When non-zero, one character
  417. is sent to the terminal at a time (does not work for MS-DOS).  This makes the
  418. screen updating a lot slower, making it possible to see what is happening.
  419.  
  420. ==============================================================================
  421. 5. Using the mouse                    *mouse-using*
  422.  
  423. This section is about using the mouse on a terminal or a terminal window.  How
  424. to use the mouse in a GUI window is explained in |gui-mouse|.
  425.  
  426. Don't forget to enable the mouse with either one of these commands:
  427. >    :set mouse=a
  428. >    :set mouse=A
  429. Otherwise Vim won't recognize the mouse in all modes (See 'mouse').
  430.  
  431. Currently the mouse is supported for Unix in an xterm window and for MS-DOS.
  432. Mouse clicks can be used to position the cursor, select the Visual area and
  433. paste.  The GUI also has menus.
  434.  
  435. The characters in the 'mouse' option tell in which situations the mouse will
  436. be used by Vim:
  437.         n    Normal mode
  438.         N    Normal mode, xterm-like selection
  439.         v    Visual mode
  440.         i    Insert mode
  441.         I    Insert mode, xterm-like selection
  442.         c    Command-line mode
  443.         h    all previous modes when in a help file
  444.         a    all previous modes, except 'N' and 'I'
  445.         A    all previous modes, except 'n' and 'i'
  446.         r    for |hit-return| prompt
  447.  
  448. The default for 'mouse' is empty, the mouse is not used.  Normally you would do
  449. >    :set mouse=a
  450. to start using the mouse (this is equivalent to setting 'mouse' to "nvich").
  451. If you only want to use the mouse in a few modes or also want to use it for
  452. the two questions you will have to concatenate the letters for those modes.
  453. For example:
  454. >    :set mouse=nv
  455. Will make the mouse work in Normal mode and Visual mode.
  456. >    :set mouse=h
  457. Will make the mouse work in help files only (so you can use "g<LeftMouse>" to
  458. jump to tags).
  459.  
  460. The 'N' and 'I' flags allow the cursor to be positioned by the mouse, but
  461. dragging the mouse doesn't start Visual mode.  Instead, xterm-like selection
  462. is used.  In the Command-line mode this always happens.  This behaviour is
  463. similar to how Windows programs work.
  464.  
  465. In an xterm, with the currently active mode included in the 'mouse' option,
  466. normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl key
  467. pressed go the the xterm.  With the currently active mode not included in
  468. 'mouse' all mouse clicks go to the xterm.
  469.  
  470. Here is how you copy and paste a piece of text:
  471.  
  472. Copy/paste with the mouse and Visual mode ('mouse' option must be set, see
  473. above):
  474. 1. Press left mouse button on first letter of text, move mouse pointer to last
  475.    letter of the text and release the button.  This will start Visual mode and
  476.    highlight the selected area.
  477. 2. Press "y" to yank the Visual text in the unnamed register.
  478. 3. Click the left mouse button at the insert position.
  479. 4. Click the middle mouse button.
  480.  
  481. Shortcut: If the insert position is on the screen at the same time as the
  482. Visual text, you can do 2, 3 and 4 all in one: Click the middle mouse button
  483. at the insert position.
  484.  
  485.                             *xterm-copy-paste*
  486. NOTE: In some (older) xterms, it's not possible to move the cursor past column
  487. 95.  This is an xterm problem, not Vim's.
  488.  
  489. Copy/paste in xterm with (current mode NOT included in 'mouse'):
  490. 1. Press left mouse button on first letter of text, move mouse pointer to last
  491.    letter of the text and release the button.
  492. 2. Use normal Vim commands to put the cursor at the insert position.
  493. 3. Press "a" to start Insert mode.
  494. 4. Click the middle mouse button.
  495. 5. Press ESC to end Insert mode.
  496. (The same can be done with anything in 'mouse' if you keep the shift key
  497. pressed while using the mouse)
  498.  
  499. Note: if you lose the 8th bit when pasting (special characters are translated
  500. into other characters), you may have to do "stty cs8 -istrip -parenb" in your
  501. shell before starting Vim.
  502.  
  503. Thus in an xterm the shift and ctrl keys cannot be used with the mouse.  To
  504. make it possible to do the mouse commands that require the ctrl modifier, the
  505. "g" key can be typed before using the mouse:
  506.     "g<LeftMouse>"    is "<C-LeftMouse>    (jump to tag under mouse click)
  507.     "g<RightMouse>" is "<C-RightMouse>    ("CTRL-T")
  508.  
  509. A short overview of what the mouse buttons do:
  510.  
  511. Normal Mode:
  512. event          position       Visual      change  action    ~
  513.            cursor              window        ~
  514. <LeftMouse>     yes         end        yes
  515. <C-LeftMouse>   yes         end        yes       "CTRL-]" (2)
  516. <S-LeftMouse>   yes      no change        yes       "*" (2)    *<S-LeftMouse>*
  517. <LeftDrag>      yes    start or extend (1) no              *<LeftDrag>*
  518. <LeftRelease>   yes    start or extend (1) no
  519. <MiddleMouse>   yes      if not active     no       put
  520. <MiddleMouse>   yes      if active        no       yank and put
  521. <RightMouse>    yes    start or extend     yes
  522. <S-RightMouse>  yes       no change        yes       "#" (2)    *<S-RightMouse>*
  523. <C-RightMouse>  no            no change        no       "CTRL-T"
  524. <RightDrag>     yes        extend        no              *<RightDrag>*
  525. <RightRelease>  yes        extend        no              *<RightRelease>*
  526.  
  527. Insert or Replace Mode:
  528. event          position       Visual      change  action    ~
  529.            cursor              window        ~
  530. <LeftMouse>     yes     (cannot be active)  yes
  531. <C-LeftMouse>   yes     (cannot be active)  yes       "CTRL-O^]" (2)
  532. <S-LeftMouse>   yes     (cannot be active)  yes       "CTRL-O*" (2)
  533. <LeftDrag>      yes     start or extend (1) no       like CTRL-O (1)
  534. <LeftRelease>   yes     start or extend (1) no       like CTRL-O (1)
  535. <MiddleMouse>   no      (cannot be active)  no       put register
  536. <RightMouse>    yes     start or extend        yes       like CTRL-O
  537. <S-RightMouse>  yes     (cannot be active)  yes       "CTRL-O#" (2)
  538. <C-RightMouse>  no         (cannot be active)  no       "CTRL-O CTRL-T"
  539.  
  540. In a help window:
  541. event          position       Visual      change  action    ~
  542.            cursor              window        ~
  543. <2-LeftMouse>   yes     (cannot be active)  no       "^]" (jump to help tag)
  544.  
  545. (1) only if mouse pointer moved since press
  546. (2) only if click is in same buffer
  547.  
  548. Clicking the left mouse button causes the cursor to be positioned.  If the
  549. click is in another window that window is made the active window.  When
  550. editing the command line the cursor can only be positioned on the
  551. command line.  When in Insert mode Vim remains in Insert mode.  If 'scrolloff'
  552. is set, and the cursor is positioned within 'scrolloff' lines from the window
  553. border, the text is scrolled.
  554.  
  555. A Visual area can be selected by pressing the left mouse button on the first
  556. character, moving the mouse to the last character, then releasing the mouse
  557. button.  You will not always see the Visual selection until you release the
  558. button, only in some versions (GUI, MS-DOS, WIN32) will the dragging be shown
  559. immediately.  Note that you can make the text scroll by moving the mouse at
  560. least one character in the first/last line in the window when 'scrolloff' is
  561. non-zero.
  562.  
  563. In Normal and Visual mode clicking the right mouse button causes the Visual
  564. area to be extended.  When clicking in a window which is editing another
  565. buffer, the Visual mode is stopped.
  566.  
  567. Double, triple and quadruple clicks are supported when the GUI is active,
  568. for MS-DOS and Win32, and for an xterm (if the gettimeofday() function is
  569. available).  Double clicking may be done to make the selection word-wise,
  570. triple clicking makes it line-wise, and quadruple clicking makes it
  571. rectangular block-wise.  For MS-DOS and xterm the time for double clicking can
  572. be set with the 'mousetime' option.  For the other systems this time is
  573. defined outside of Vim.
  574.  
  575. In Insert mode, when a Visual area is selected, Vim goes into Normal mode
  576. temporarily.  When Visual mode ends, it returns to Insert mode.  This is like
  577. using CTRL-O in Insert mode.
  578.  
  579.                             *drag-status-line*
  580. When working with several windows, the size of the windows can be changed by
  581. dragging the status line with the mouse.  Point the mouse at a status line,
  582. press the left button, move the mouse to the new position of the status line,
  583. release the button.  Just clicking the mouse in a status line makes that window
  584. the current window, without moving the cursor.  If by selecting a window it
  585. will change position or size, the dragging of the status line will look
  586. confusing, but it will work (just try it).
  587.  
  588. Mouse clicks can be mapped.  The codes for mouse clicks are:
  589.      code        mouse button          normal action    ~
  590.  <LeftMouse>     left pressed            set cursor position
  591.  <LeftDrag>     left moved while pressed   extend Visual area
  592.  <LeftRelease>     left released            set Visual area end
  593.  <MiddleMouse>     middle pressed            paste text at cursor position
  594.  <MiddleDrag>     middle moved while pressed -
  595.  <MiddleRelease> middle released        -
  596.  <RightMouse>     right pressed            extend Visual area
  597.  <RightDrag>     right moved while pressed  extend Visual area
  598.  <RightRelease>  right released            set Visual area end
  599.  
  600. Examples:
  601. >    :noremap <MiddleMouse> <LeftMouse><MiddleMouse>
  602. Paste at the position of the middle mouse button click (otherwise the paste
  603. would be done at the cursor position).
  604.  
  605. >    :noremap <LeftRelease> <LeftRelease>y
  606. Immediately yank the Visually highlighted text.
  607.  
  608. Note the use of ":noremap" instead of "map" to avoid a recursive mapping.
  609.  
  610.                         *mouse-swap-buttons*
  611. To swap the meaning of the left and right mouse buttons:
  612. >    :noremap    <LeftMouse>    <RightMouse>
  613. >    :noremap    <LeftDrag>    <RightDrag>
  614. >    :noremap    <LeftRelease>    <RightRelease>
  615. >    :noremap    <RightMouse>    <LeftMouse>
  616. >    :noremap    <RightDrag>    <LeftDrag>
  617. >    :noremap    <RightRelease>    <LeftRelease>
  618. >    :noremap    g<LeftMouse>    <C-RightMouse>
  619. >    :noremap    g<RightMouse>    <C-LeftMouse>
  620. >    :noremap!    <LeftMouse>    <RightMouse>
  621. >    :noremap!    <LeftDrag>    <RightDrag>
  622. >    :noremap!    <LeftRelease>    <RightRelease>
  623. >    :noremap!    <RightMouse>    <LeftMouse>
  624. >    :noremap!    <RightDrag>    <LeftDrag>
  625. >    :noremap!    <RightRelease>    <LeftRelease>
  626.  
  627.  vim:tw=78:ts=8:sw=8:
  628.